package labox.innovation.gameserver.skills.conditions;

import labox.innovation.gameserver.skills.Env;

/**
 * @author mkizub
 * 
 */
public class ConditionLogicNot extends Condition {

	protected Condition _condition;

	public ConditionLogicNot(Condition condition) {
		_condition = condition;
		if (getListener() != null)
			_condition.setListener(this);
	}

	/**
	 * 
	 * @see labox.innovation.gameserver.skills.conditions.Condition#setListener(labox.innovation.gameserver.skills.conditions.ConditionListener)
	 */
	@Override
	void setListener(ConditionListener listener) {
		if (listener != null)
			_condition.setListener(this);
		else
			_condition.setListener(null);
		super.setListener(listener);
	}

	/**
	 * 
	 * @see labox.innovation.gameserver.skills.conditions.Condition#testImpl(labox.innovation.gameserver.skills.Env)
	 */
	@Override
	public boolean testImpl(Env env) {
		return !_condition.test(env);
	}
}
